//
//  BaseNavigationController.m
//  CROSBY
//
//  Created by Harvey on 2017/10/3.
//  Copyright © 2017年 Haley. All rights reserved.
//

#import "BaseNavigationController.h"
#import "LSGraffitiViewController.h"

@interface BaseNavigationController ()

@end

@implementation BaseNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initSetting];
}

- (void)initSetting
{
    float version = [[[UIDevice currentDevice] systemVersion] floatValue];
    if (version <=7.0) {
        return;
    }
    
    self.navigationBar.translucent = NO;
//    UIImage *image = [UIImage imageNamed:@"title_bg"];
//    [self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    self.navigationBar.barTintColor = kNavigationBgColor;
    self.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationBar setBarStyle:UIBarStyleBlack];
    //让导航栏地下的黑线消失
    self.navigationBar.shadowImage = [UIImage new];
    
    [UIBarButtonItem appearance].tintColor = [UIColor whiteColor];
//    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
//                                                         forBarMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateNormal];//将title 文字的颜色改为透明
}

//支持旋转
- (BOOL)shouldAutorotate{
     return YES;
}

 //支持的方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    UIViewController *vc =  self.topViewController;
    if([vc isKindOfClass:[LSGraffitiViewController class]]){//要横屏的界面
        return UIInterfaceOrientationMaskLandscapeRight;
    }
    
    return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    UIViewController *vc =  self.topViewController;
    if([vc isKindOfClass:[LSGraffitiViewController class]]){//要横屏的界面
        return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
